﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel.Composition.Primitives;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;

namespace SilverlightApplication3
{
    public partial class MainPage : UserControl
    {
        [Import("Message")]
        public object Message; 
        public MainPage()
        {
            //compose it
            var catalog = new PackageCatalog();
            catalog.AddPackage(Package.Current);
            var container = new CompositionContainer(catalog);
            container.ComposeParts(this);

            //now bind it
            InitializeComponent();
            //var message = new SimpleHello();
            LayoutRoot.DataContext = Message;
        }
    }

    [Export("Message")]
    public class SimpleHello
    {
        public override string ToString()
        {
            return "Hello World -- 3!";
        }
    }
}
